package com.example.springboot.service;

import com.example.springboot.entity.Companies;
import com.example.springboot.entity.students;
import com.example.springboot.entity.user;
import com.example.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public List<user> findAll() {
       return userMapper.findAll();
    }
    public void addUser(user user) {
        userMapper.addUser(user);
    }

    public void updateUserByUsername(user user) {
        userMapper.updateUserByUsername(user);
    }

    public void editUserByUsername(user user) {
        userMapper.editUserByUsername(user);
    }

    public void deleteUser(int user_id) {
        userMapper.deleteUser(user_id);
    }

    public void deleteAccountBatch(List<Long> ids) {
        userMapper.deleteAccountStuBatch(ids);
        userMapper.deleteAccountBossBatch(ids);
        userMapper.deleteAccountBatch(ids);
    }

    public List<user>  selectByName(String username) {
        return userMapper.selectByName(username);
    }

    public void addBoss(Companies companies) {
        userMapper.addBossUser(companies);
    }

    public void addStu(students student) {
        userMapper.addStuUser(student);
    }

    public List<students> selectStuAll() {
        return userMapper.selectStuAll();
    }

    public List<Companies> selectBossAll() {
        return userMapper.selectBossAll();
    }

    public void deleteBossUser(int userId) {
        userMapper.deleteBossUser(userId);
    }

    public void deleteStuUser(int userId) {
        userMapper.deleteStuUser(userId);
    }
}
